@extends('layouts.back_stage')
@section('style')
    @parent
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/customers.css?v1.1.8" rel="stylesheet">
@endsection
@section('content')
<div class="container"><!--融合框架的时候把这里的CSS宽度改一下就好-->
    <div class="container_box">
        <div class="chartshead">
            <h3 style="display: inline;">财务信息</h3>
        </div>
        <div class="income_record">
                <div class="income_record_head">
                    <div class="finance_company_box" style="padding-top:10px;padding-left:10px;">
                        <p><b>年份:</b></p>
                        <select  class="address" id="select_year" style="padding:0 12px;width:130px;">
                            <option value="2018" checked>2018年</option>
                            <option value="2017">2017年</option>
                        </select>
                        <p><b>月份:</b></p>
                        <select  class="address" id="select_month" style="padding:0 12px;width:130px;">
                            <option value="" checked>请选择</option>
                            <option value="1">1月</option>
                            <option value="2">2月</option>
                            <option value="3">3月</option>
                            <option value="4">4月</option>
                            <option value="5">5月</option>
                            <option value="6">6月</option>
                            <option value="7">7月</option>
                            <option value="8">8月</option>
                            <option value="9">9月</option>
                            <option value="10">10月</option>
                            <option value="11">11月</option>
                            <option value="12">12月</option>
                        </select>
                        <p><b>品牌：</b></p>
                        <select class="address" id="select_brand" style="padding:0 12px;width:130px;">
                            <option value="">请选择</option>
                            <option value="1">Soyyos</option>
                            <option value="2">SoonWord</option>
                        </select>
                        <p><b>公司：</b></p>
                        <select  class="address" id="select_area" style="padding:0 12px;width:130px;">
                            <option value="">请选择</option>
                            @foreach($companys as $k => $v)
                            <option value="{{ $k }}">{{$v}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <table id="income_record_details">
                    <thead>
                        <tr>
                            <td class="col-md-1">周期</td>
                            <td class="col-md-1">收入(元)</td>
                            <td class="col-md-1">外围价(元)</td>
                            <td class="col-md-1">服务费(元)</td>
                            <td class="col-md-1">邮费(元)</td>
                            <td class="col-md-1">利润(元)</td>
                            <td class="col-md-1">净收入(元)</td>
                            <td class="col-md-1">退款(元)</td>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            <h3 id="showTips" style="text-align: center;margin-top:100px;">请选择品牌、区域、团队进行查询</h3>
        </div>
    </div>
</div>
<script type="text/javascript">
    var date;
    var totalPrice;
    var costPrice;
    var returnPrice;
    var serverPrice;
    var netIncome;
    var profitPrice;
    var today = new Date();
    $(document).ready(function () {
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
            },
            type:'post',
            url:'/finance/financeLog',
            data:{
                area_id:'',
                brand_id:'',
                company_id:'',
                year:'2018',
                times:'',
                type:1
            },
            dataType: 'json',
            success:function (res) {
                $("#income_record_details tbody tr").remove();
                if(res.success != true){
                    $(".faceImg").attr("src","/img/weep.png");
                    $(".oHandle").text("请先选择品牌、区域、款号");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    return false;
                }
                var totalPriceSum=0;
                var costPriceSum=0;
                var returnPriceSum=0;
                var serverPriceSum=0;
                var netIncomeSum=0;
                var profitPriceSum=0;
                for (var m = 12;m > 0;m--){
                    jQuery.each(res.info, function(i, val){
                        date = parseInt(i);
                        if(date == m){
                            if(res.info[i] == ""){
                                totalPrice = 0;
                                costPrice = 0;
                                returnPrice = 0;
                                serverPrice = 0;
                                netIncome = 0;
                                profitPrice = 0;
                                totalPriceSum = 0;
                                costPriceSum = 0;
                                returnPriceSum = 0;
                                serverPriceSum = 0;
                                netIncomeSum = 0;
                                profitPriceSum = 0;
                            }else{
                                totalPrice = val.total_price;
                                costPrice = val.cost_price;
                                returnPrice = val.return_price;
                                serverPrice = val.service_price;
                                netIncome = totalPrice-returnPrice-serverPrice;
                                profitPrice = netIncome-costPrice;
                                totalPriceSum += res.info[i].total_price;
                                costPriceSum += res.info[i].cost_price;
                                returnPriceSum += res.info[i].return_price;
                                serverPriceSum += res.info[i].service_price;
                                netIncomeSum += totalPrice-returnPrice-serverPrice;
                                profitPriceSum += netIncome-costPrice;
                            }
                            totalPrice = totalPrice.toFixed(2);
                            costPrice = costPrice.toFixed(2);
                            returnPrice = returnPrice.toFixed(2);
                            serverPrice = serverPrice.toFixed(2);
                            netIncome = netIncome.toFixed(2);
                            profitPrice = profitPrice.toFixed(2);
                            $("#income_record_details tbody").append("<tr><td>"+date+"月</td><td>"+totalPrice+"</td><td>"+costPrice+"</td><td>"+serverPrice+"</td><td>N/A</td><td>"+netIncome+"</td><td>"+profitPrice+"</td><td>"+returnPrice+"</td></tr>")
                        }
                    });
                }
                if(res.info == ""){
                    $("#showTips").text("无收入");
                }else{
                    $("#showTips").text("");
                    $("#income_record_details tbody").prepend("<tr style='background-color:#f1f1f1;'><td>全部</td><td>"+totalPriceSum.toFixed(2)+"</td><td>"+costPriceSum.toFixed(2)+"</td><td>"+serverPriceSum.toFixed(2)+"</td><td>N/A</td><td>"+profitPriceSum.toFixed(2)+"</td><td>"+netIncomeSum.toFixed(2)+"</td><td>"+returnPriceSum.toFixed(2)+"</td></tr>")
                }
            }
        })
    });
    //年份切换月汇总
    $("#select_year").change(function () {
        var brand_id = $("#select_brand").val();
        var area_id = $("#select_area").val();
        var years = $(this).val();
        var months = $("#select_month").val();
        var type = 1;
        if(months == ""){
            type = 1;
        }else{
            type = 0;
        }
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
            },
            type:'post',
            url:'/finance/financeLog',
            data:{
                brand_id:brand_id,
                company_id:area_id,
                year:years,
                times:months,
                type:type
            },
            dataType: 'json',
            success:function (res) {
                $("#income_record_details tbody tr").remove();
                if(res.success != true){
                    $(".faceImg").attr("src","/img/weep.png");
                    $(".oHandle").text("请先选择品牌、区域、款号");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    return false;
                }
                var totalPriceSum=0;
                var costPriceSum=0;
                var returnPriceSum=0;
                var serverPriceSum=0;
                var netIncomeSum=0;
                var profitPriceSum=0;
                for (var m = 12;m > 0;m--){
                    jQuery.each(res.info, function(i, val){
                        date = parseInt(i);
                       if(date == m){
                           if(res.info[i] == ""){
                               totalPrice = 0;
                               costPrice = 0;
                               returnPrice = 0;
                               serverPrice = 0;
                               netIncome = 0;
                               profitPrice = 0;
                               totalPriceSum = 0;
                               costPriceSum = 0;
                               returnPriceSum = 0;
                               serverPriceSum = 0;
                               netIncomeSum = 0;
                               profitPriceSum = 0;
                           }else{
                               totalPrice = val.total_price;
                               costPrice = val.cost_price;
                               returnPrice = val.return_price;
                               serverPrice = val.service_price;
                               netIncome = totalPrice-returnPrice-serverPrice;
                               profitPrice = netIncome-costPrice;
                               totalPriceSum += res.info[i].total_price;
                               costPriceSum += res.info[i].cost_price;
                               returnPriceSum += res.info[i].return_price;
                               serverPriceSum += res.info[i].service_price;
                               netIncomeSum += totalPrice-returnPrice-serverPrice;
                               profitPriceSum += netIncome-costPrice;
                           }
                           totalPrice = totalPrice.toFixed(2);
                           costPrice = costPrice.toFixed(2);
                           returnPrice = returnPrice.toFixed(2);
                           serverPrice = serverPrice.toFixed(2);
                           netIncome = netIncome.toFixed(2);
                           profitPrice = profitPrice.toFixed(2);
                           $("#income_record_details tbody").append("<tr><td>"+date+"月</td><td>"+totalPrice+"</td><td>"+costPrice+"</td><td>"+serverPrice+"</td><td>N/A</td><td>"+netIncome+"</td><td>"+profitPrice+"</td><td>"+returnPrice+"</td></tr>")
                       }
                    });
                }
                if(res.info == ""){
                    $("#showTips").text("无收入");
                }else{
                    $("#showTips").text("");
                    $("#income_record_details tbody").prepend("<tr style='background-color:#f1f1f1;'><td>全部</td><td>"+totalPriceSum.toFixed(2)+"</td><td>"+costPriceSum.toFixed(2)+"</td><td>"+serverPriceSum.toFixed(2)+"</td><td>N/A</td><td>"+profitPriceSum.toFixed(2)+"</td><td>"+netIncomeSum.toFixed(2)+"</td><td>"+returnPriceSum.toFixed(2)+"</td></tr>")
                }
            }
        })
    });
    $("#select_month").change(function(){
        var brand_id = $("#select_brand").val();
        var area_id = $("#select_area").val();
        var years = $("#select_year").val();
        var months = $(this).val();
        var type = 0;
        if(months == ""){
            type = 1;
            $("#income_record_details tbody tr").remove();
            return false;
        }else{
            type = 0;
        }
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
            },
            type:'post',
            url:'/finance/financeLog',
            data:{
                brand_id:brand_id,
                company_id:area_id,
                type:type,
                year:years,
                time:months
            },
            dataType: 'json',
            success:function (res) {
                if(res.info != ""){
                    $("#income_record_details tbody tr").remove();
                    if(res.success != true){
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text("请先选择品牌、区域、款号");
                        $(".oSuccess").show(0).delay(1000).hide(0);
                        return false;
                    }
                    var totalPriceSum=0;
                    var costPriceSum=0;
                    var returnPriceSum=0;
                    var serverPriceSum=0;
                    var netIncomeSum=0;
                    var profitPriceSum=0;
                    if(months == today.getMonth()+1 && years == today.getYear()){
                        for(var i = today.getDate();i>0;i--){
                            if(res.info[i] !== undefined){
                                netIncome = res.info[i].total_price-res.info[i].service_price-res.info[i].return_price;
                                profitPrice = netIncome-res.info[i].cost_price;
                                $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>"+res.info[i].total_price.toFixed(2)+"</td><td>"+res.info[i].cost_price.toFixed(2)+"</td><td>"+res.info[i].service_price.toFixed(2)+"</td><td>N/A</td><td>"+profitPrice.toFixed(2)+"</td><td>"+netIncome.toFixed(2)+"</td><td>"+res.info[i].return_price.toFixed(2)+"</td></tr>")
                            }else{
                                $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>0.00</td><td>0.00</td><td>0.00</td><td>N/A</td><td>0.00</td><td>0.00</td><td>0.00</td></tr>")
                            }
                        }
                    }else{
                        if(months == "1" || months == "3" || months == "5" || months == "7" || months == "8" || months == "10" || months == "12"){
                            for(var i = 31;i>0;i--){
                                if(res.info[i] !== undefined){
                                    netIncome = res.info[i].total_price-res.info[i].service_price-res.info[i].return_price;
                                    profitPrice = netIncome-res.info[i].cost_price;
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>"+res.info[i].total_price.toFixed(2)+"</td><td>"+res.info[i].cost_price.toFixed(2)+"</td><td>"+res.info[i].service_price.toFixed(2)+"</td><td>N/A</td><td>"+profitPrice.toFixed(2)+"</td><td>"+netIncome.toFixed(2)+"</td><td>"+res.info[i].return_price.toFixed(2)+"</td></tr>")
                                }else{
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>0.00</td><td>0.00</td><td>0.00</td><td>N/A</td><td>0.00</td><td>0.00</td><td>0.00</td></tr>")
                                }
                            }
                        }else if(months == "2"){
                            for(var i = 29;i>0;i--){
                                if(res.info[i] !== undefined){
                                    netIncome = res.info[i].total_price-res.info[i].service_price-res.info[i].return_price;
                                    profitPrice = netIncome-res.info[i].cost_price;
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>"+res.info[i].total_price.toFixed(2)+"</td><td>"+res.info[i].cost_price.toFixed(2)+"</td><td>"+res.info[i].service_price.toFixed(2)+"</td><td>N/A</td><td>"+profitPrice.toFixed(2)+"</td><td>"+netIncome.toFixed(2)+"</td><td>"+res.info[i].return_price.toFixed(2)+"</td></tr>")
                                }else{
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>0.00</td><td>0.00</td><td>0.00</td><td>N/A</td><td>0.00</td><td>0.00</td><td>0.00</td></tr>")
                                }
                            }

                        }else if(months == "4" || months == "6" || months == "9" || months == "11"){
                            for(var i = 30;i>0;i--){
                                if(res.info[i] !== undefined){
                                    netIncome = res.info[i].total_price-res.info[i].service_price-res.info[i].return_price;
                                    profitPrice = netIncome-res.info[i].cost_price;
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>"+res.info[i].total_price.toFixed(2)+"</td><td>"+res.info[i].cost_price.toFixed(2)+"</td><td>"+res.info[i].service_price.toFixed(2)+"</td><td>N/A</td><td>"+profitPrice.toFixed(2)+"</td><td>"+netIncome.toFixed(2)+"</td><td>"+res.info[i].return_price.toFixed(2)+"</td></tr>")
                                }else{
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>0.00</td><td>0.00</td><td>0.00</td><td>N/A</td><td>0.00</td><td>0.00</td><td>0.00</td></tr>")
                                }
                            }
                        }
                    }

                    jQuery.each(res.info, function(i, val) {
                        date = parseInt(i);
                        if(res.info[i] == ""){
                            totalPrice = 0;
                            costPrice= 0 ;
                            returnPrice = 0;
                            serverPrice = 0;
                            netIncome = 0;
                            profitPrice = 0;
                            totalPriceSum = 0;
                            returnPriceSum = 0;
                            serverPriceSum = 0;
                            netIncomeSum = 0;
                            profitPriceSum = 0;
                        }else{
                            totalPrice = val.total_price;
                            costPrice = val.cost_price;
                            returnPrice = val.return_price;
                            serverPrice = val.service_price;
                            netIncome = totalPrice-returnPrice-serverPrice;
                            profitPrice = netIncome-costPrice;
                            totalPriceSum += res.info[i].total_price;
                            costPriceSum += res.info[i].cost_price;
                            returnPriceSum += res.info[i].return_price;
                            serverPriceSum += res.info[i].service_price;
                            netIncomeSum += totalPrice-returnPrice-serverPrice;
                            profitPriceSum += netIncome-costPrice;
                        }
                        totalPrice = totalPrice.toFixed(2);
                        costPrice = costPrice.toFixed(2);
                        returnPrice = returnPrice.toFixed(2);
                        serverPrice = serverPrice.toFixed(2);
                        netIncome = netIncome.toFixed(2);
                        profitPrice = profitPrice.toFixed(2);
                    });
                    $("#showTips").text("");
                    $("#income_record_details tbody").prepend("<tr style='background-color:#f1f1f1;'><td>全部</td><td>"+totalPriceSum.toFixed(2)+"</td><td>"+costPriceSum.toFixed(2)+"</td><td>"+serverPriceSum.toFixed(2)+"</td><td>N/A</td><td>"+profitPriceSum.toFixed(2)+"</td><td>"+netIncomeSum.toFixed(2)+"</td><td>"+returnPriceSum.toFixed(2)+"</td></tr>")
                }else{
                    $("#income_record_details tbody tr").remove();
                    $("#showTips").text("无收入");
                }

            }
        })
    });
    function orderAjax(){
        var brand_id = $("#select_brand").val();
        var area_id = $("#select_area").val();
        var years = $("#select_year").val();
        var months = $("#select_month").val();
        var type = 0;
        if(months == ""){
            type = 1;
        }else{
            type = 0;
        }
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
            },
            type:'post',
            url:'/finance/financeLog',
            data:{
                brand_id:brand_id,
                company_id:area_id,
                type:type,
                year:years,
                time:months
            },
            dataType: 'json',
            success:function (res) {
                if(type == 0){
                    $("#income_record_details tbody tr").remove();
                    if(res.success != true){
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text("请先选择品牌、区域、款号");
                        $(".oSuccess").show(0).delay(1000).hide(0);
                        return false;
                    }
                    var totalPriceSum=0;
                    var costPriceSum=0;
                    var returnPriceSum=0;
                    var serverPriceSum=0;
                    var netIncomeSum=0;
                    var profitPriceSum=0;
                    if(months == today.getMonth()+1 && years == today.getYear()){
                        for(var i = today.getDate();i>0;i--){
                            if(res.info[i] !== undefined){
                                netIncome = res.info[i].total_price-res.info[i].service_price-res.info[i].return_price;
                                profitPrice = netIncome-res.info[i].cost_price;
                                $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>"+res.info[i].total_price.toFixed(2)+"</td><td>"+res.info[i].cost_price.toFixed(2)+"</td><td>"+res.info[i].service_price.toFixed(2)+"</td><td>N/A</td><td>"+profitPrice.toFixed(2)+"</td><td>"+netIncome.toFixed(2)+"</td><td>"+res.info[i].return_price.toFixed(2)+"</td></tr>")
                            }else{
                                $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>0.00</td><td>0.00</td><td>0.00</td><td>N/A</td><td>0.00</td><td>0.00</td><td>0.00</td></tr>")
                            }
                        }
                    }else{
                        if(months == "1" || months == "3" || months == "5" || months == "7" || months == "8" || months == "10" || months == "12"){
                            for(var i = 31;i>0;i--){
                                if(res.info[i] !== undefined){
                                    netIncome = res.info[i].total_price-res.info[i].service_price-res.info[i].return_price;
                                    profitPrice = netIncome-res.info[i].cost_price;
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>"+res.info[i].total_price.toFixed(2)+"</td><td>"+res.info[i].cost_price.toFixed(2)+"</td><td>"+res.info[i].service_price.toFixed(2)+"</td><td>N/A</td><td>"+profitPrice.toFixed(2)+"</td><td>"+netIncome.toFixed(2)+"</td><td>"+res.info[i].return_price.toFixed(2)+"</td></tr>")
                                }else{
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>0.00</td><td>0.00</td><td>0.00</td><td>N/A</td><td>0.00</td><td>0.00</td><td>0.00</td></tr>")
                                }
                            }
                        }else if(months == "2"){
                            for(var i = 29;i>0;i--){
                                if(res.info[i] !== undefined){
                                    netIncome = res.info[i].total_price-res.info[i].service_price-res.info[i].return_price;
                                    profitPrice = netIncome-res.info[i].cost_price;
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>"+res.info[i].total_price.toFixed(2)+"</td><td>"+res.info[i].cost_price.toFixed(2)+"</td><td>"+res.info[i].service_price.toFixed(2)+"</td><td>N/A</td><td>"+profitPrice.toFixed(2)+"</td><td>"+netIncome.toFixed(2)+"</td><td>"+res.info[i].return_price.toFixed(2)+"</td></tr>")
                                }else{
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>0.00</td><td>0.00</td><td>0.00</td><td>N/A</td><td>0.00</td><td>0.00</td><td>0.00</td></tr>")
                                }
                            }

                        }else if(months == "4" || months == "6" || months == "9" || months == "11"){
                            for(var i = 30;i>0;i--){
                                if(res.info[i] !== undefined){
                                    netIncome = res.info[i].total_price-res.info[i].service_price-res.info[i].return_price;
                                    profitPrice = netIncome-res.info[i].cost_price;
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>"+res.info[i].total_price.toFixed(2)+"</td><td>"+res.info[i].cost_price.toFixed(2)+"</td><td>"+res.info[i].service_price.toFixed(2)+"</td><td>N/A</td><td>"+profitPrice.toFixed(2)+"</td><td>"+netIncome.toFixed(2)+"</td><td>"+res.info[i].return_price.toFixed(2)+"</td></tr>")
                                }else{
                                    $("#income_record_details tbody").append("<tr><td>"+i+"日</td><td>0.00</td><td>0.00</td><td>0.00</td><td>N/A</td><td>0.00</td><td>0.00</td><td>0.00</td></tr>")
                                }
                            }
                        }
                    }
                    jQuery.each(res.info, function(i, val) {
                        date = parseInt(i);
                        if(res.info[i] == ""){
                            totalPrice = 0;
                            costPrice= 0 ;
                            returnPrice = 0;
                            serverPrice = 0;
                            netIncome = 0;
                            profitPrice = 0;
                            totalPriceSum = 0;
                            returnPriceSum = 0;
                            serverPriceSum = 0;
                            netIncomeSum = 0;
                            profitPriceSum = 0;
                        }else{
                            totalPrice = val.total_price;
                            costPrice = val.cost_price;
                            returnPrice = val.return_price;
                            serverPrice = val.service_price;
                            netIncome = totalPrice-returnPrice-serverPrice;
                            profitPrice = netIncome-costPrice;
                            totalPriceSum += res.info[i].total_price;
                            costPriceSum += res.info[i].cost_price;
                            returnPriceSum += res.info[i].return_price;
                            serverPriceSum += res.info[i].service_price;
                            netIncomeSum += totalPrice-returnPrice-serverPrice;
                            profitPriceSum += netIncome-costPrice;
                        }
                        totalPrice = totalPrice.toFixed(2);
                        costPrice = costPrice.toFixed(2);
                        returnPrice = returnPrice.toFixed(2);
                        serverPrice = serverPrice.toFixed(2);
                        netIncome = netIncome.toFixed(2);
                        profitPrice = profitPrice.toFixed(2);
                    });
                    $("#showTips").text("");
                    $("#income_record_details tbody").prepend("<tr style='background-color:#f1f1f1;'><td>全部</td><td>"+totalPriceSum.toFixed(2)+"</td><td>"+costPriceSum.toFixed(2)+"</td><td>"+serverPriceSum.toFixed(2)+"</td><td>N/A</td><td>"+profitPriceSum.toFixed(2)+"</td><td>"+netIncomeSum.toFixed(2)+"</td><td>"+returnPriceSum.toFixed(2)+"</td></tr>")
                }else if(type == 1){
                    $("#income_record_details tbody tr").remove();
                    if(res.success != true){
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text("请先选择品牌、区域、款号");
                        $(".oSuccess").show(0).delay(1000).hide(0);
                        return false;
                    }
                    var totalPriceSum=0;
                    var costPriceSum=0;
                    var returnPriceSum=0;
                    var serverPriceSum=0;
                    var netIncomeSum=0;
                    var profitPriceSum=0;
                    for (var m = 12;m > 0;m--){
                        jQuery.each(res.info, function(i, val){
                            date = parseInt(i);
                            if(date == m){
                                if(res.info[i] == ""){
                                    totalPrice = 0;
                                    costPrice = 0;
                                    returnPrice = 0;
                                    serverPrice = 0;
                                    netIncome = 0;
                                    profitPrice = 0;
                                    totalPriceSum = 0;
                                    costPriceSum = 0;
                                    returnPriceSum = 0;
                                    serverPriceSum = 0;
                                    netIncomeSum = 0;
                                    profitPriceSum = 0;
                                }else{
                                    totalPrice = val.total_price;
                                    costPrice = val.cost_price;
                                    returnPrice = val.return_price;
                                    serverPrice = val.service_price;
                                    netIncome = totalPrice-returnPrice-serverPrice;
                                    profitPrice = netIncome-costPrice;
                                    totalPriceSum += res.info[i].total_price;
                                    costPriceSum += res.info[i].cost_price;
                                    returnPriceSum += res.info[i].return_price;
                                    serverPriceSum += res.info[i].service_price;
                                    netIncomeSum += totalPrice-returnPrice-serverPrice;
                                    profitPriceSum += netIncome-costPrice;
                                }
                                totalPrice = totalPrice.toFixed(2);
                                costPrice = costPrice.toFixed(2);
                                returnPrice = returnPrice.toFixed(2);
                                serverPrice = serverPrice.toFixed(2);
                                netIncome = netIncome.toFixed(2);
                                profitPrice = profitPrice.toFixed(2);
                                $("#income_record_details tbody").append("<tr><td>"+date+"月</td><td>"+totalPrice+"</td><td>"+costPrice+"</td><td>"+serverPrice+"</td><td>N/A</td><td>"+netIncome+"</td><td>"+profitPrice+"</td><td>"+returnPrice+"</td></tr>")
                            }
                        });
                    }
                    if(res.info == ""){
                        $("#showTips").text("无收入");
                    }else{
                        $("#showTips").text("");
                        $("#income_record_details tbody").prepend("<tr style='background-color:#f1f1f1;'><td>全部</td><td>"+totalPriceSum.toFixed(2)+"</td><td>"+costPriceSum.toFixed(2)+"</td><td>"+serverPriceSum.toFixed(2)+"</td><td>N/A</td><td>"+profitPriceSum.toFixed(2)+"</td><td>"+netIncomeSum.toFixed(2)+"</td><td>"+returnPriceSum.toFixed(2)+"</td></tr>")
                    }
                }

            }
        })
    }
    $("#select_brand").change(function () {
        orderAjax();
    });
    $("#select_company").change(function () {
        orderAjax();
    })
    $("#select_area").change(function () {
        orderAjax();
    })
</script>
@endsection
@section('style')
    @parent
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/style.css?v=4.1.0" rel="stylesheet">
@endsection